<template>
	<view class="activeDetailContainer">

		<!-- 活动详情的展开 -->
		<view class="expandCard">
			<view class="expandCardTop">
				<text class="acticeNickName">{{activityDetailInfo.activityName}}</text>
				<text class="createTime">创建时间: {{activityDetailInfo.createTime}}</text>
				<!-- 活动详情 -->
				<view class="activeDetail">
					活动详情
				</view>
			</view>

			<mote-lines-divide :line="4" :dt="activityDetailInfo.activityDescription" expandText="展开" foldHint="收起">

			</mote-lines-divide>
		</view>
		
		<view style="height: 190rpx;"></view>
		<image class="img-36" @click="getForward()" src="../../static/36.png"></image>
		
	</view>
</template>

<script>
	import MoteLinesDivide from "../../components/mote-lines-divide/mote-lines-divide.vue"

	import Card from '../../components/Card/Card.vue'
	import showDataCard from '../../components/showDataNum/showDataNum.vue'
	export default {
		components: {
			showDataCard,
			Card,
			MoteLinesDivide
		},

		data() {
			return {
				// 活动id
				activity_id: '',
				code: '', //核销码
				// 活动详情信息
				activityDetailInfo: {},
				activityType: null,
				// 活动列表组件
				activeList: [{
						img: '../../static/38.png',
						text: '活动预览',
						type: this.activityType, //type值动态获取
						id: 0,
						activityDetail: true,
						activityId: ''
					},
					{
						img: '../../static/40.png',
						text: '中奖名单',
						id: 1,
						activityDetail: true,

					},
					{
						img: '../../static/39.png',
						text: '用户数据',
						id: 2,
						activityDetail: true

					},

				],

				// 不显示
				isshowDataCard: false
			}
		},
		onLoad(options) {
			
			if (options.id) {
				this.activity_id = options.id;
				this.activityDetailFn()
			}
			if (options.code) {
				this.code = options.code;
			}
		},
		
		onShow() {
			this.$at.releaseKey('write');
		},

		methods: {

			//核销
			getForward() {
				this.$at.uniDoFunc({
					// 键名
					key: 'write',
					// 是否立即触发,默认触发
					// instant: true,
					success: async () => {
						//锁定
						this.$at.lockKey('write');
						const result = await this.$http.get({
							url: this.$api.saveVerificationCode,
							data: {
								merchantId: uni.getStorageSync('merchantId'),
								staffId: uni.getStorageSync('staffId'),
								verificationCode: this.code,
								shopCodeId: this.activity_id,
							}
						});
						if (result.code == 2000) {
							this.$at.releaseKey('write');
							uni.showModal({
								title: '提示',
								content: result.msg,
								showCancel: false,
								success: res => {
									uni.navigateBack();
								}
							});
						} else {
							this.$at.releaseKey('write');
							this.$sun.toast(result.msg, 'none');
						}
					}
				});
			},
			

			//活动详情
			async activityDetailFn() {
				const result = await this.$http.get({
					url: this.$api.selectGetId,
					data: {
						id: this.activity_id,
					}
				});
				// 获取详情信息
				if (result.code == 2000) {
					// 这里进行判断 如果是视频快推 只显示活动预览页面 快手显示活动预览页面和用户数据 视频号也是活动阅览页面
					//              如果是大转盘和九宫格 就不需要显示出视频号 抖音显示活动预览 和中奖名单 快手显示  活动预览 和中奖名单 用户数据
					//              如果是卡券 不显示视频号 抖音显示活动预览 和中奖名单 快手显示  活动预览 和中奖名单 用户数据              
					// 获取是抖音还是快手
					
					if (result.data.releaseChannel == 3) {
						// 不显示数据
						this.isshowDataCard = true
					}
					
					if (result.data.releaseChannel == 3 && result.data.activityType == 1) {
						this.activeList = [{
								img: '../../static/38.png',
								text: '活动预览',
								type: this.activityType, //type值动态获取
								id: 0,
								activityDetail: true,
								activityId: ''
							},
							{
								img: '../../static/39.png',
								text: '用户数据',
								id: 2,
								activityDetail: true
					
							},
					
						]
					}
					if ((result.data.releaseChannel == 1||result.data.releaseChannel==2) && result.data.activityType == 1) {
						this.activeList = [{
								img: '../../static/38.png',
								text: '活动预览',
								type: this.activityType, //type值动态获取
								id: 0,
								activityDetail: true,
								activityId: ''
							},
					
						]
					}
					if ((result.data.releaseChannel == 1) &&( result.data.activityType == 2||result.data.activityType==3)) {
						this.activeList = [{
								img: '../../static/38.png',
								text: '活动预览',
								type: this.activityType, //type值动态获取
								id: 0,
								activityDetail: true,
								activityId: ''
							},
							{
								img: '../../static/40.png',
								text: '中奖名单',
								id: 1,
								activityDetail: true,
							
							},
					
						]
					}
					if ((result.data.releaseChannel == 1) &&( result.data.activityType == 2||result.data.activityType==3||result.data.activityType==4)) {
						this.activeList = [{
								img: '../../static/38.png',
								text: '活动预览',
								type: this.activityType, //type值动态获取
								id: 0,
								activityDetail: true,
								activityId: ''
							},
							{
								img: '../../static/40.png',
								text: '中奖名单',
								id: 1,
								activityDetail: true,
							
							},
					
						]
					}
					if ((result.data.releaseChannel == 3) &&( result.data.activityType == 2||result.data.activityType==3||result.data.activityType==4)) {
						this.activeList = [{
								img: '../../static/38.png',
								text: '活动预览',
								type: this.activityType, //type值动态获取
								id: 0,
								activityDetail: true,
								activityId: ''
							},
							{
								img: '../../static/40.png',
								text: '中奖名单',
								id: 1,
								activityDetail: true,
							
							},
							{
								img: '../../static/39.png',
								text: '用户数据',
								id: 2,
								activityDetail: true
							
							},
					
						]
					}
							
					this.activityDetailInfo = result.data
					// 这个是活动类型
					this.activeList[0].type = result.data.activityType
					// 这个是活动id
					this.activeList[0].activityId = result.data.id
				}else {
					uni.showModal({
						title: '提示',
						content: result.msg,
						showCancel: false,
						success: res => {
							uni.navigateBack();
						}
					});
				}
			},
		}
	}
</script>

<style lang="less">
	
	.img-36 {
		width: 412rpx;
		height: 78rpx;
		position: fixed;
		bottom: 100rpx;
		left: 168rpx;
	}
	
	.activeDetailContainer {
		padding: 20rpx 20rpx 0 20rpx;
		// height: 100vh;

		.expandCard {
			width: 710rpx;

			border-radius: 5px;
			position: relative;
			background: linear-gradient(180deg, #161736 0%, rgba(101, 104, 246, 0.08) 0.01%, #FFF 100%);
			padding: 0 32rpx 42rpx 32rpx;

			.expandCardTop {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-bottom: 18rpx;

				.acticeNickName {
					margin: 38rpx 0 18rpx 0;

					color: #000;
					font-size: 32rpx;
					font-family: Inter;
					font-weight: 700;
				}

				.createTime {
					color: #757575;
					font-size: 24rpx;
					font-family: Inter;
				}

				.activeDetail {
					margin-top: 42rpx;
					color: #A1A1A1;
					font-size: 28rpx;

					font-weight: 700;

					&::after {
						content: "";
						display: block;
						font-size: 0;
						height: 2rpx;
						width: 218rpx;
						background-color: #dadada;
						position: absolute;
						left: 442rpx;
						top: 190rpx;

					}

					&::before {
						content: "";
						display: block;
						font-size: 0;
						height: 2rpx;
						width: 218rpx;
						background-color: #dadada;
						position: absolute;
						left: 50rpx;
						top: 190rpx;

					}
				}
			}
		}
	}
</style>